<?php

    /**
     * @package      Modules
     * @subpackage   Core_Controllers_Admin
     *
     * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
     */
    class Core_Controllers_Admin_Cron extends Core_Controller_Action_Abstract
    {

	////////////////////////////////////////////////////////////////////////////
	//                                Variables                               //
	////////////////////////////////////////////////////////////////////////////

	    /**
	     * Parameters for plugins
	     *
	     * @var array
	     */
        protected $_pluginParams = array();

        /**
         * Default namespace
         *
         * @var Zend_Session_Namespace
         */
        protected $_namespace = null;

	////////////////////////////////////////////////////////////////////////////
	//                                 Methods                                //
	////////////////////////////////////////////////////////////////////////////

        public function index()
        {
            $group  = $this->_getParam('group');
            $crons  = array();

            $registry = Zend_Registry::getInstance();

            if (!Zend_Registry::isRegistered('crons')) {
                $registry['crons'] = Core_Cron_Compiler::get();
            }

            if ($group === null) {
                foreach ($registry['crons'] as $group => $groupedCrons) {
                    $crons[] = $groupedCrons;
                }
            } else if (array_key_exists($group, $registry['crons'])) {
                $crons[] = $registry['crons'][$group];
            } else {
                throw new Core_Exception('Crons group name must exists in crons.xml');
            }

            foreach ($crons as $group) {
                foreach ($group as $selector) {
                    $url = Core_Url::get($selector);
                    var_dump($url);
                }
            }

            exit();
        }
    }
